<template>
  <el-form class="add-event-vote">
    <el-divider content-position="center">全局票数设置</el-divider>
    <input-normal label="每个用户每天分配票数" v-model="wbData.day_limit" @change="onUpdateWbComponent"></input-normal>
    <switch-normal v-model="wbData.isUid" label="个人行为" @change="onUpdateWbComponent"></switch-normal>
    <input-normal label="系数" v-model="wbData.vote_coefficient"  @change="onUpdateWbComponent"></input-normal>
    <input-normal label="触发投票关联id" v-model="wbData.syn_com_id" @change="onUpdateWbComponent"></input-normal>
    <textarea-normal v-if="wbData.syn_com_id && wbData.syn_com_id.length > 0" label="关联投票ids" placeholder="请在此处输入关联的ids" v-model="wbData.syn_vote_ids" @change="onUpdateWbComponent"></textarea-normal>
    <el-collapse v-model="activeNames">
      <el-collapse-item v-for="(item, key, index) in eventWbLists" :name="index+1" :key="index">
          <template #title>
          投票列表项{{index+1}}
        </template>
        <input-normal class="margin-top-10" label="调整投票基数" placeholder="请在此处输入调整投票基数" v-model="item.base" @change="onUpdateWbItem(key)"></input-normal>
        <input-normal label="限制投票数" placeholder="请在此处输入限制投票数" v-model="item.total" @change="onUpdateWbItem(key)"></input-normal>
      </el-collapse-item>
    </el-collapse>
  </el-form>
</template>

<script>
  import InputNormal from '@/views/components/edit/InputNormal.vue'
  import TextareaNormal from '@/views/components/edit/TextareaNormal.vue'
  import SwitchNormal from '@/views/components/edit/SwitchNormal.vue'

  import { mapActions, mapState } from 'vuex'
  import { addUtils } from '@/views/js/add-utils'
  // 
  // import { getMainEventControlId } from '@/store/utils';

  export default {
    mixins: [addUtils],
    components: {
      InputNormal,
      TextareaNormal,
      SwitchNormal,
    },
    computed: {
      ...mapState({
        lists: (state) => state.components.currentComponentData.lists,
        componentData: (state) => state.components.currentComponentData,
      }),
    },
    methods: {
      ...mapActions({
      }),
      onUpdateWbItem(key){
        let controlId = this.event.controlId
        let params = {item: this.eventWbLists[key], index:key, controlId};
        this.updateWbComponentItem(params);
      },
    },
  };
</script>
